[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 PUSH EXP[,EXP...]

 Function
  Push (save) one or more evaluated expressions to the stack.

 Syntax
  PUSH exp[,exp]

   exp  - An expression of any type to evaluate and push.

 Remarks
  This statement will evalutate one or more expressions of any type and
  push the results onto the stack for temporary storage.  The results of
  those expressions may be retrieved via the POP statement.  Together PUSH
  and POP can be used for parameter passing, to create 'local' variables,
  or to reverse the order of arguments.

 Examples
  INTEGER i, tc
  STRING  s
  LET tc = TOKCOUNT()
  WHILE (TOKCOUNT() > 0) PUSH GETTOKEN() ' push them in order
  FOR i = 1 TO tc
   POP s                                 ' pop them in reverse
   PRINTLN s
  NEXT

  INTEGER i
  FOR i = 1 TO 10
   PRINT i," - "
   GOSUB sub
  NEXT
  END
  :sub
  PUSH i                                 ' temporarily save i
  LET i = i*i
  PRINTLN i
  POP i                                  ' restore saved i
  RETURN

  INTEGER v
  PRINT "A cube with dimensions 2X3X4"
  PUSH 2,3,4                             ' pass pushed parameters
  GOSUB vol
  POP v                                  ' pop result
  PRINTLN "has volume ",v
  END
  :vol
  INTEGER w,h,d
  POP d,h,w                              ' pop passed parameter
  PUSH w*h*d                             ' push result
  RETURN

See Also: POP
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson